hysop.backend.device.opencl.opencl_kernel_launcher module¶
- class hysop.backend.device.opencl.opencl_kernel_launcher.HostLauncherI(name, **kwds)[source]¶
Bases:
LauncherI
Create a OpenClKernelLauncher.
- Parameters:
- class hysop.backend.device.opencl.opencl_kernel_launcher.LauncherI(name, profiler=None, **kwds)[source]¶
Bases:
object
Interface for any object that has the ability to be a launcher.
Create a OpenClKernelLauncher.
- Parameters:
- abstract __call__(queue=None, wait_for=None, **kwds)[source]¶
Launch with a specific queue. Wait for wait_for events before computing. If queue has profiling enabled, events are pushed into a local list of events to compute kernel statistics when self.statistics is fetched.
- property events¶
All events since the last call to update statistics.
- abstract global_size_configured()[source]¶
Return True is this kernel is ready to be enqueued without specifying global_work_size (local_work_size is always optional).
- property name¶
Get the name of this kernel launcher.
- property statistics¶
Compute statistics and clear events of kernels that finished.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClIterativeKernelLauncher(parameters_map, args_list, iterated_parameters, **kwds)[source]¶
Bases:
OpenClParametrizedKernelLauncher
Wraps an OpenCL kernel ready to be iteratively enqueued with some extra kernel arguments. Extra kernel arguments may be splitted between:
An OpenClIterativeKernelLauncher is acting like an OpenClKernelListLauncher without the need of generating the list of all kernels with fixed arguments.
Create a OpenClIterativeKernelLauncher.
- Parameters:
args_list (tuple) – Known arguments of the kernel, as a tuple of tuples (arg_index, arg_value).
parameters_map (dict) – Mapping between unknown parameter names and (parameter_index, parameter_type).
iterated_parameters (dict) – Mapping between iterated parameter names and OpenClKernelParameterGenerator. Iterated parameters should be included in parameters_map as well.
kwds (dict) – Base class parameters.
- __call__(queue=None, wait_for=None, enqueue_barrier=True, global_work_size=None, local_work_size=None, **kwds)[source]¶
Launch kernel with a specific queue, global_work_size and local_work_size. Wait for wait_for events before computing. If queue has profiling enabled, events are pushed into a local list of events to compute kernel statistics when self.statistics is fetched.
If the queue is out of order, a barrie is enqueued unless enqueue_barrier is set to False. If enqueue_barrier is False, returned event is None.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClKernelLauncher(name, kernel, args_list, default_global_work_size=None, default_local_work_size=None, default_queue=None, **kwds)[source]¶
Bases:
OpenClKernelLauncherI
Wraps an OpenCL kernel ready to be enqueued without extra arguments. Manage launching of one OpenCL kernel with fixed arguments.
Create a OpenClKernelLauncher.
- Parameters:
name (str) – A name for this kernel launcher (for logging purposes).
kernel (cl.Program or cl.Kernel) – The precompiled program that contains the kernel to be launched. If a program is passed we can create a unique instance of a kernel that will have its arguments already set.
args_list (tuple) – All arguments of the kernel, in the right order as a tuple or tuple of tuples (arg_index, arg_value).
default_queue (cl.CommandQueue, optional) – Default queue to run the kernel.
default_global_work_size (tuple of ints, optional) – Default global work size.
default_local_work_size (tuple of ints, optional) – Default local work size.
kwds (dict) – Base class arguments.
- __call__(queue=None, wait_for=None, global_work_size=None, local_work_size=None, **kwds)[source]¶
Launch kernel with a specific queue, global_work_size and local_work_size. Wait for wait_for events before computing. If queue has profiling enabled, events are pushed into a local list of events to compute kernel statistics when self.statistics is fetched.
- property args_list¶
All arguments of the kernel as a tuple.
- property default_queue¶
Default queue to launch the kernel.
- global_size_configured()[source]¶
Return True is this kernel is ready to be enqueued without specifying global_work_size (local_work_size is always optional).
- property kernel¶
Get the precompiled kernel to be launched.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClKernelLauncherI(name, profiler=None, **kwds)[source]¶
Bases:
LauncherI
Interface for any object that has the ability to enqueue a OpenCL kernel without extra arguments.
Create a OpenClKernelLauncher.
- Parameters:
- abstract __call__(queue=None, wait_for=None, global_work_size=None, local_work_size=None, **kwds)[source]¶
Launch kernel with a specific queue. Wait for wait_for events before computing. If queue has profiling enabled, events are pushed into a local list of events to compute kernel statistics when self.statistics is fetched.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClKernelListLauncher(name, profiler=None)[source]¶
Bases:
object
Wraps multiples OpenCL kernel ready to be enqueued without extra arguments. All kernels contained in a KernelListLauncher are called with the same queue (ie. OpenClKernelLauncher default_queue is not taken into account and all kernels
should at least have a pre-configured global_work_size).
Create a OpenClKernelListLauncher.
- Parameters:
- __call__(queue, wait_for=None, **kwds)[source]¶
Enqueue all kernels on the given queue in order. The first enqueued kernel will wait on the wait_for events. If this OpenClKernelListLauncher is empty, cl.wait_for_events will be called instead.
- property name¶
Return the OpenClKernelLauncher name.
- property parameters¶
Return parameters of OpenClParametrizedKernelLauncher. This is a mapping between the parameter names and parameter types and operator names.
- push_copy_device_to_device(varname, src, dst, src_device_offset=None, dst_device_offset=None, byte_count=None)[source]¶
Shortcut for OpenClCopyDevice2Device kernels creation.
- push_copy_device_to_host(varname, src, dst, src_device_offset=None)[source]¶
Shortcut for OpenClCopyDevice2Host kernels creation.
- push_copy_host_device(varname, src, dst, src_device_offset=None, dst_device_offset=None, byte_count=None)[source]¶
Shortcut for OpenClCopyBuffer kernels creation.
- push_copy_host_to_device(varname, src, dst, dst_device_offset=None)[source]¶
Shortcut for OpenClCopyHost2Device kernels creation.
- push_kernels(*kernel_launchers)[source]¶
Push OpenClKernelLaunchers into the list. None values are ignored for convenience.
- property statistics¶
Compute statistics of each kernels and clear events of kernels that finished.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClKernelParameterGenerator[source]¶
Bases:
object
Abstract base for opencl kernel parameter yielders.
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClKernelParameterYielder(fn)[source]¶
Bases:
OpenClKernelParameterGenerator
Generate opencl parameters through an external iterator or generator factory.
Create a OpenClKernelParameterYielder.
- Parameters:
fn (callable) –
Lambda, function or functor that takes no arguments which should return a Generator or an Iterator uppon call.
- Example:
lambda: range(10)
- class hysop.backend.device.opencl.opencl_kernel_launcher.OpenClParametrizedKernelLauncher(parameters_map, args_list, **kwds)[source]¶
Bases:
OpenClKernelLauncher
Wraps an OpenCL kernel ready to be enqueued with some extra kernel arguments.
Create a OpenClParametrizedKernelLauncher.
- Parameters:
- property parameters_map¶
Mapping between parameter names and (parameter_index, parameter_type).
- hysop.backend.device.opencl.opencl_kernel_launcher.profile_kernel(kernel, evt, kernel_msg=None, fprofiler=None)[source]¶
- hysop.backend.device.opencl.opencl_kernel_launcher.should_profile_kernel(kernel_msg)¶